This page contains my suggestions on documentation style. I will try to demonstrate my suggestions by writing a document that justifies them. I'm an advocate of learning by example. As Mark Twain said, "Few things are harder to put up with than the annoyance of a good example" (Samuel Langhornne Clemens (1835-1910)). Pulling content from CVSA large part of the WebWork 2.2 documentation effort is to make documentation easier to handle in the future. At on the onset of this effort, everyone agreed that pulling as much source code, examples, and documentation from source control would help greatly. As such, we've installed a modified version of the snippet macro in the OpenSymphony wiki.
The standard way to use it is to do the following: {snippet:id=description|javadoc=true|url=com.opensymphony.xwork.interceptor.LoggingInterceptor} or {snippet:id=example|javadoc=true|lang=xml|url=com.opensymphony.xwork.interceptor.LoggingInterceptor} or {snippet:id=sitegraph-usage|lang=none|url=webwork/src/java/com/opensymphony/webwork/sitegraph/sitegraph-usage.txt} or {snippet:id=ajax-validation-example|lang=xml|url=webwork/webapps/ajax/src/webapp/lesson1/example.jsp} Where:
All snippets are marked off by the pattern START SNIPPET: XXX and END SNIPPET: XXX where XXX is the name of the snippet that is assigned in the id attribute of the macro. The URL is typically a location that points to the project's source control contents. A note about URLsAs you probably noticed in the examples, there are several formats that the URL patterns can be in. A fully-qualified URL is always allowed, though that is often not practical. We've customized the macro to be a bit more intelligent with the URL attribute:
Note that the short-hand class notation will only work for top-level projects (WebWork, OSWorkflow, etc) and not any sub-projects within the projects, such as example webapps in WebWork. If you wish to include content from a class in a sub-project, you'll need to list out the full path, like in the fourth example. A note about snippet markersAll snippet markers should be commented out if possible. How they are commented out depends on where the snippet is. If the snippet is for HTML or XML, you can do: <!-- START SNIPPET: xxx --> ... <!-- END SNIPPET: xxx --> If the snippet is in Java code, you can do: if (true != false) { // START SNIPPET: xxx System.out.println("This is some silly code!"); // END SNIPPET: xxx } If the snippet is found in JavaDocs, you should use HTML comments as they won't render in the JavaDocs. For XML examples in JavaDocs (see Timer Interceptor for an example), it can be a bit tricky. This is because in your JavaDocs you want to use the <pre> tag, but you don't want the wiki to display it. A good technique is to embed the snippet markers inside the <pre> tag: * <pre> * <!-- START SNIPPET: example --> * <!-- records only the action's execution time --> * <action name="someAction" class="com.examples.SomeAction"> * <interceptor-ref name="completeStack"/> * <interceptor-ref name="timer"/> * <result name="success">good_result.ftl</result> * </action> * <!-- END SNIPPET: example --> About HeadingsThis section refers to: Notation Guide >> Headings. Headings should definetly be used. This sections tries to justify why. First rule: don't use "h1" at the top of each page. The page title serves as the "top level header" already, so there is no need to duplicate that information again. Also, when the docs end up the website, SiteMesh will place a top level "h1" element using the page title. Document sectionsHeadings can help you divide your document in sections, subsections, sub-subsections and so forth. AdvantagesYour document becomes more organized. DisadvantagesIf you exaggerate you could fragment your text too much.
Headings capitalizationI think headers h1 and h2 should have all words capitalized (such as "Vitor's Suggestions on Documentation Style" and "About Headings"), but h3 and smaller would have just the first word (such as "Headings capitalization"). Except, of course, for words that are always capitalized (eg. "Understanding WebWork's importance to OpenSymphony and its community"). This gives even more importance to bigger headings. Avoid skipping headersI mean, avoid going from a h1 directly to a h3 without using h2 before. This would be like havin a section 1.1.1 directly below section 1, without the existance of section 1.1.
More on Text EffectsThis section refers to: Notation Guide >> Text Effects. Text effects should be largely used, although I have some questions on some of them. Strong, emphasis, and inserted can be used to denote importante parts of a sentence. But I really think inserted should have been called underline in the notation guide. I don't see the point of using I can't think of a situation in WebWork's doc for superscript and subscript, but it doesn't hurt to mention them. I can't say anything about %span% because I frankly don't know what it does. Monospaced is heavily used, for instance, to refer to webwork-default.xml file or items in source code examples: <xmltag />, JavaClass or javaVariable.
Colors should be used in very specific cases, or else each documentation writers would color his/her pages the way he/she thinks it's better, and it would look like a mess. One such specific case in which colors can help is when you want them to work as tags or captions. For (a lame) example, in this paragraph, guidelines are in red and justifications are in blue. Yes, it's a really really lame example, I know. Text BreaksThis section refers to: Notation Guide >> Text Breaks. Text breaks shouldn't be used. If you'd like paragraphs or headings to have more spacing (before or after), the style sheet should be changed, not the contents. Patrick explained this a long time ago. Other stuff in this section (paragraphs, horizontal ruler, — symbol and – symbol) can be used when necessary. LinksThis section refers to: Notation Guide >> Links. All types of links can and should be used. I already used a few in this document. Just watch out for links to non-existing pages when writing on the official documentation. ListsThis section refers to: Notation Guide >> Lists. Lists can be used for many purposes. Every time we list some things that are in order, ordered lists are used. If they don't have a specific order, unordered lists are the case. List should be nested if needed for a better organization. Unordered lists should be created only with the * (star) notation only, so all pages use the same style of bullet.
Images and IconsThis section refers to: Notation Guide >> Images and Notation Guide >> Misc. External images should be used only when strictly necessary (meaning, don't use images as list bullets or box icons). Also, try to use only images that are very unlikely to be removed from its current URL, to reduce document maintenance. Pay attention on copyright issues too! Attached images are less prone to become missing links, however, we should not clutter the documentation with unnecessary attachments and copyrights are also a issue here. Example: Cannot resolve external resource into attachment. Icons are cool in a number of situations. Some of them, such as , , or can make the documentation look professional, but some others, such as and may give a feeling of amateurship and I wouldn't advise them for pages that are exported to form the official documentation. TablesThis section refers to: Notation Guide >> Tables. Tables are very useful when lists just don't do it. Meaning: don't write a table when a list suffices. Tables are more organized, because you can align the text in columns. Since the markup text for tables in confluence is not very easy to read, remember complex and big tables are very hard to maintain. The table below was copied from a reference page on WebWork's configuration (just the first two lines were copied). This is an example where tables are good: a list wouldn't be as organized as this table to display these files and their properties.
Advanced FormattingThis section refers to: Notation Guide >> Advanced Formatting. I've already made my point about info, warning, tip and note boxes. Other interesting markups are noformat and code. The former can be used for general purpose text while the latter is used to display example source code, be it HTML, XML, Java or anything that is part of a software solution. When displaying something that has a name, use a title, as the example below demonstrates. HelloWorld.java /** Hello World class. */ public class HelloWorld { /** Main method. */ public static void main(String[] args) { System.out.println("Hello, World!"); } } A typical example of noformat would be the command line statements to compile and run the code above. We should also standardize terminal notation ({$} for command prompt). $ javac HelloWorld.java $ java HelloWorld Hello, World! Do not use tabs inside noformat and code, use two spaces instead. This way your code is indented but keeps lines short. Large lines should be splitted as to fit in a 800x600 resolution screen without horizontal scroll bars. Your Comments PleasePlease contribute to this page. Let me know if you have a different opinion on something (please justify it). Please warn me if I wrote something wrong or if this proposed Style Guide is missing something. Feel free to correct my english, since I'm not a native speaker. |